package cn.cj.erp.bo.system;

import cn.cj.erp.common.SearchParam;
import cn.cj.erp.common.annotation.Search;
import cn.cj.erp.common.enums.SearchType;
import cn.cj.erp.common.enums.StatusEnum;
import cn.cj.erp.common.enums.YesNoEnum;
import cn.cj.erp.common.utils.id.IdGenerator;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;

/**
 * 通知公告用户阅读表
 * 
 * @author chenjian
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class SysNoticeUserReadBo extends SearchParam {

    /** 通知公告用户阅读表ID */
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;

    /** 通知公告ID */
    @JsonSerialize(using = ToStringSerializer.class)
    private Long noticeId;

    /** 系统用户id */
    @JsonSerialize(using = ToStringSerializer.class)
    private Long userId;

    /** 是否已读{@link YesNoEnum}，仅在指定通知接收人时使用 */
    private YesNoEnum readStatus;

    /** 状态 */
    private StatusEnum status;

    /** 备注 */
    private String remark;

    /** 创建时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    /** 更新时间 */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date modifyTime;

    @Search(type = SearchType.LIKE, fieldName = "id")
    private String key;

    /**
     * 创建对象
     * @param userId 用户ID
     * @param noticeId 公告ID
     * @return 实体类
     */
    public static SysNoticeUserReadBo newInstance(Long userId, Long noticeId) {
        return newInstance(userId, noticeId, "");
    }

    /**
     * 创建对象
     * @param userId 用户ID
     * @param noticeId 公告ID
     * @return 实体类
     */
    public static SysNoticeUserReadBo newInstance(Long userId, Long noticeId, String remark) {
        SysNoticeUserReadBo bo = new SysNoticeUserReadBo();
        bo.setId(IdGenerator.generateId());
        bo.setNoticeId(noticeId);
        bo.setUserId(userId);
        bo.setReadStatus(YesNoEnum.YES);
        bo.setStatus(StatusEnum.NORMAL);
        bo.setRemark(remark);
        return bo;
    }
}
